package models

import "gorm.io/gorm"

type GroupModel struct {
	gorm.Model
	GroupName   string      `gorm:"type:varchar(100);not null" json:"groupName"` // 群名称
	GroupHeader string      `gorm:"type:varchar(255)" json:"groupHeader"`        // 群头像 URL
	CreateBy    int         `gorm:"type:int" json:"create_by"`
	Users       []UserBasic `gorm:"many2many:user_groups;foreignKey:ID;joinForeignKey:GroupId;References:ID;joinReferences:UserId" json:"users"`
}

type UserGroup struct {
	gorm.Model
	UserId  uint
	GroupId uint
}

func (ug UserGroup) TableName() string {
	return "user_groups"
}

func (g GroupModel) TableName() string {
	return "groups"
}
